import { resolve } from 'path'

import loadConfig from 'load-config-path/tsx'
export interface LintGuardOptions {
    config?: any
    cwd?: string
    concurrent?: boolean | number
    maxArgLength?: number
    shell?: boolean
    quiet?: boolean
    relative?: boolean
    debug?: boolean
    stash?: boolean
    allowEmpty?: boolean
    // 自定义配置项
    customFormatters?: Array<(results: any) => void>
    beforeHooks?: Array<() => Promise<void>>
    afterHooks?: Array<(success: boolean, results: any) => Promise<void>>
    onError?: (error: any) => void
}
export const getConfigFile = async function (path: string) {
    try {
        const configPath = resolve(path)
        const configObj = await loadConfig<Record<string, string>>(
            resolve(configPath, './.lintrc.ts')
        )
        return configObj
    } catch {
        return {}
    }
}
